import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },

  {
    path: '/form',
    component: Layout,
    redirect: '/form/menu1',
    name: 'Form',
    meta: {
      title: '数据管理',
      icon: 'nested'
    },
    children: [
      {
        path: 'menu1',
        component: () => import('@/views/nested/menu1/index'), // Parent router-view
        name: 'Menu1',
        meta: { title: '数据源管理' },
        children: [
          {
            path: 'menu1-1',
            component: () => import('@/views/nested/menu1/menu1-1'),
            name: 'Menu1-1',
            meta: { title: '更改数据源' }
          },
          {
            path: 'menu1-2',
            component: () => import('@/views/dataManagement/workorderdata/index'),
            name: 'Menu1-2',
            meta: { title: '更改数据项' }
          }
        ]
      },
      {
        path: 'menu2',
        component: () => import('@/views/nested/menu2/index'),
        meta: { title: '数据监控' }
      }
    ]
  },

  /*   {
    path: '/form',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Form',
        component: () => import('@/views/form/index'),
        meta: { title: '数据管理', icon: 'form' }
      }
    ]
  }, */

  {
    path: '/nested',
    component: Layout,
    redirect: '/nested/menu1',
    name: 'Nested',
    meta: {
      title: '数据可视化',
      icon: 'nested'
    },
    children: [
      {
        path: 'menu1',
        component: () => import('@/views/nested/menu1/index'), // Parent router-view
        name: 'Menu1',
        meta: { title: '总体数据可视化' },
        children: [
          {
            path: 'menu1-1',
            component: () => import('@/views/visual/service/index'),
            name: 'Menu1-1',
            meta: { title: '服务指标' }
          },
          {
            path: 'menu1-2',
            component: () => import('@/views/chartTest/index'),
            name: 'Menu1-2',
            meta: { title: '图表类型' },
            children: [
              // {
              //   path: 'menu1-2-1',
              //   component: () => import('@/views/chartTest/stackLine/index'),
              //   name: '玫瑰图',
              //   meta: { title: '玫瑰图' }
              // },
              {
                path: 'menu1-2-2',
                component: () => import('@/views/chartTest/wordCloud/index'),
                name: '柱形图',
                meta: { title: '柱形图' }
              }
              // {
              //   path: 'menu1-2-2',
              //   component: () => import('@/views/chartTest/test/index'),
              //   name: '测试',
              //   meta: { title: '测试' }
              // }
            ]
          }
        ]
      },
      {
        path: 'menu2',
        component: () => import('@/views/visual/keyindex/index'),
        name: '关键指标数据可视化',
        meta: { title: '关键指标数据可视化' }
      },
      {
        path: 'test',
        component: () => import('@/views/chartTest/test/index'),
        name: '测试',
        meta: { title: '测试' }
      },
      {
        // path: 'menu1-3',
        // component: () => import('@/views/nested/menu1/menu1-3'),
        // name: 'Menu1-3',
        // meta: { title: '大屏编辑区' }
        path: 'bigScreenReport',
        component: () => import('@/views/bigScreenReport/index'),
        name: '大屏编辑区',
        meta: { title: '大屏编辑区' }
      }
    ]
  },
  {
    path: '/bigscreen/viewer',
    component: () => import('@/views/bigscreenDesigner/viewer'),
    hidden: true,
    meta: {
      requireAuth: true
    }
  },
  // {
  //   path: '/bigscreen/designer',
  //   component: () => import('@/views/bigscreenDesigner/designer'),
  //   hidden: true,
  //   meta: {
  //     requireAuth: true
  //   }
  // },
  {
    path: '/group',
    component: Layout,
    redirect: '/nested/menu1',
    name: 'Nested',
    meta: {
      title: '指标与标签管理',
      icon: 'nested'
    },
    children: [
      {
        path: 'menu1',
        component: () => import('@/views/nested/menu1/index'), // Parent router-view
        name: 'Menu1',
        meta: { title: '指标管理' },
        children: [
          {
            path: 'menu1-1',
            component: () => import('@/views/nested/menu1/menu1-1'),
            name: 'Menu1-1',
            meta: { title: '指标组合' }
          }
        ]
      },
      {
        path: 'menu2',
        component: () => import('@/views/nested/menu2/index'),
        meta: { title: '标签管理' },
        children: [
          {
            path: 'menu2-1',
            component: () => import('@/views/nested/menu2/menu2-1'),
            name: 'Menu2-1',
            meta: { title: '标签组合' }
          }
        ]
      }
    ]
  },

  {
    path: '/report',
    component: Layout,
    redirect: '/nested/menu1',
    name: 'Nested',
    meta: {
      title: '报表管理',
      icon: 'nested'
    },
    children: [
      {
        path: 'menu1',
        component: () => import('@/views/visual/keyindex/index'), // Parent router-view
        name: 'Menu1',
        meta: { title: '报表生成' },
        children: [
          {
            path: 'menu1-1',
            component: () => import('@/views/nested/menu1/menu1-1'),
            name: 'Menu1-1',
            meta: { title: '投诉风险' }
          },
          {
            path: 'menu1-2',
            component: () => import('@/views/nested/menu1/menu1-2'),
            name: 'Menu1-2',
            meta: { title: '全区域服务统计' }
          },
          {
            path: 'menu1-3',
            component: () => import('@/views/nested/menu1/menu1-3'),
            name: 'Menu1-3',
            meta: { title: '服务效能' }
          }
        ]
      }
    ]
  },

  {
    path: '/customer',
    component: Layout,
    redirect: '/nested/menu1',
    name: 'Nested',
    meta: {
      title: '用户画像',
      icon: 'nested'
    },
    children: [
      {
        path: 'menu1',
        component: () => import('@/views/nested/menu1/index'), // Parent router-view
        name: 'Menu1',
        meta: { title: '用户管理' }
      },
      {
        path: 'menu2',
        component: () => import('@/views/customer/risk/index'),
        meta: { title: '风险维度' }
      }
    ]
  },

  {
    path: '/example',
    component: Layout,
    redirect: '/example/table',
    name: 'Example',
    meta: { title: '账号管理', icon: 'example' },
    children: [
      {
        path: 'table',
        name: 'Table',
        component: () => import('@/views/table/index'),
        meta: { title: '账号管理', icon: 'table' }
      },
      {
        path: 'tree',
        name: 'Tree',
        component: () => import('@/views/tree/index'),
        meta: { title: '权限管理', icon: 'tree' }
      }
    ]
  },

  {
    path: 'external-link',
    component: Layout,
    children: [
      {
        path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
        meta: { title: '友情链接', icon: 'link' }
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
